package com.midian.action.mc.advertisepic;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.midian.action.mc.common.AjaxAction;
import com.midian.common.annotation.FileModelDetails;
import com.midian.common.annotation.FunctionAnnotationOverride;
import com.midian.model.advertisepic.AdvertisePic;
import com.midian.model.common.FileModel;
import com.midian.service.advertisepic.IAdvertisePicService;
import com.midian.service.pic.IPicService;

/**
 * 机构Action
 * 
 * @author Mengfh
 *
 */
@Scope("prototype")
@Controller("advertisePic")
@FunctionAnnotationOverride(isAction = true, auth = "启动页图片管理")
public class AdvertisePicAction extends AjaxAction<AdvertisePic>{
	/** 广告图片实体 */
	private AdvertisePic entity;
	/** 广告图片列表 */
	private List<AdvertisePic> rows;
	/** 广告图片业务 */
	private IAdvertisePicService advertisePicService;
	/**图片*/
	private FileModel indexAdvertisePic;
	
	/**图片业务*/
	private IPicService picService;
	
	@Resource(name = "picService")
	public void setPicService(IPicService picService) {
		this.picService = picService;
	}

	@Resource(name = "advertisePicService")
	public void setAdvertisePicService(IAdvertisePicService advertisePicService) {
		this.advertisePicService = advertisePicService;
		this.service = advertisePicService;
	}

	@Override
	protected AdvertisePic dytEntity() {
		if (this.entity == null) {
			this.entity = new AdvertisePic();
		}
		return getEntity();
	}

	@Override
	protected void dyEntity(AdvertisePic t) {
		setEntity(t);
	}

	@Override
	public List<AdvertisePic> getRows() {
		return rows;
	}
	
	@FileModelDetails(fieldName = "indexAdvertisePic.id",isDelOldFile = false)
	public FileModel getIndexAdvertisePic() {
		return indexAdvertisePic;
	}

	public void setIndexAdvertisePic(FileModel indexAdvertisePic) {
		this.indexAdvertisePic = indexAdvertisePic;
	}

	
	@Override
	public void setRows(List<AdvertisePic> rows) {
		this.rows=rows;
	}

	
	public AdvertisePic getEntity() {
		return entity;
	}

	public void setEntity(AdvertisePic entity) {
		this.entity = entity;
	}
	
	@Override
	public String saveInfo() {
		System.out.println(entity.getUrl());
		System.out.println(entity.getIndexAdvertisePic());
		return super.saveInfo();
	}

}
